home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
uw_1.exe
/
UW_HELP6.HLP
< prev
next >
Wrap
Text File
|
1992-11-13
|
22KB
|
512 lines
`co(4,7);──────────────────────────── /// Print Support ───────────────────────────────`co();
`keyword(Introduction,/// Introduction);
`keyword(Key Structure Elements,/// Key Structure Elements);
┌──────────────────────────────────────────────────────────────────────────┐
│ `keyword(init_printer,/// init_printer); `keyword(end_printer,/// end_printer); │
│ `keyword(print_char,/// print_char); `keyword(print_data,/// print_data); │
│ `keyword(print_eol,/// print_eol); `keyword(print_file,/// print_file); │
│ `keyword(print_screen,/// print_screen); `keyword(print_str,/// print_str); │
│ `keyword(print_window,/// print_window); `keyword(realloc_printer,/// realloc_printer); │
│ `keyword(set_prt_xlat,/// set_prt_xlat); `keyword(print_in_bkgrnd,/// print_in_bkgrnd); │
└──────────────────────────────────────────────────────────────────────────┘
`co(4,7);─────────────────────────── /// Introduction ─────────────────────────────────`co();
These routines are primarily designed for printing to a printer.
However, printing can be output to a DOS file or device (com1, lpt1,
tmp.dat, etc). UltraWin can have as many as four print queues active and
printing concurrently! The queuing routines are unique in the fact that
they can "dynamically" reallocate themselves and "grow" and "shrink" on the
fly without losing a single byte of data. The reallocation routines take
advantage of the lightning fast movmem, as much out of convenience as
speed. An 8Mhz 286 can queue 25,000 bytes worth of text strings in one
second, reallocating every 2048 bytes; really quite remarkable. The
output is very fast. Under normal operation, a "write" occurs on every
byte, resulting in ~1024 bytes per second (on the same machine). Not many
printers can keep up with this speed! Even greater speed is achieved by
using "block mode", where each write can output 512 bytes at a time. This
is not done by default since outputting to a comm port at a slow baud rate
could hamper overall performance.
`color(RED,LIGHTGRAY);─────────────────────── /// Key Structure Elements ───────────────────────────`color();
Several print structure elements are of importance. These elements can
be modified directly for the desired effect.
The `co(15,1);halt`co(); member controls output from the queue. If 1, output stops
and the data in the queue remains unmodified. If set to 0, output
continues.
The `co(15,1);block_mode`co(); member controls the number of bytes output per
call to the function "print_in_bkgnd". If 0, only one byte per call will
be output. This is useful for communication devices or printers. If
outputting to a file or laser printer, setting block mode to 1 will allow
up to 512 bytes to be output per call, thereby increasing performance.
This value is defined in UW.H. Changing this value and recompiling
UW_PRINT.C will allow you to change the number of bytes sent per block.
The `co(15,1);xlat`co(); and `co(15,1);xlat_flag`co(); control printer translation. See `keyword(set_prt_xlat,/// set_prt_xlat);
for more details.
`co(10,1);/// init_printer`co(); `keyword(source,[UW_PRINT.C]~init_printer);
Initializes a printer queue. Printer queues can be either ram-based or
disk-based. If ram-based, a queue can be no greater than 64k. Disk-based
queues can be up to 2 gigabytes. (Though we have never actually tried this
size!). If disk-based, the initial and maximum size should be set to the
same value, and a second filename is used as a disk buffer. Be sure that
the isize and msize values are "long". If any error occurs (file cannot be
open, memory cannot be allocated,etc) a 0 will be returned.
Prototype:
int init_printer( char *fname, char *diskbuff, long isize,
long msize, PRINT *p );
Parameters:
`co(11,1); char *fname`co();
A pointer to a string containing the filename/device to print to.
`co(11,1); char *diskbuff`co();
A pointer to a string containing the filename/device to use as a disk
buffer. This is NULL for ram-based queues.
`co(11,1); long isize`co();
The initial size of the print queue. (Maximum 64k if ram based)
`co(11,1); long msize`co();
The maximum size of the print queue. (Maximum 64k if ram based)
isize and msize should be set equal if using a disk based queue.
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1, printer2;
...
if( !init_printer("out1.prt", NULL, 2048L, 16384L, &printer1) )
wn_plst(0,0,"cannot initialize printer", wnp);
if( !init_printer("out2.prt", "disk.buf", 32768L, 32768L, &printer2) )
wn_plst(0,0,"cannot initialize printer", wnp);
`co(10,1);/// end_printer`co(); `keyword(source,[UW_PRINT.C]~end_printer);
Closes any files and frees any memory used by the print queue. If
disk-based, the temporary disk file is left intact so that it will not
have to be recreated during the next program execution. You may delete
this file yourself if desired.
Prototype:
int end_printer( PRINT *p );
Parameters:
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1;
...
end_printer(&printer1);
`co(10,1);/// print_char`co(); `keyword(source,[UW_PRINT.C]~print_char);
Prints a single character. A 0 is returned if an error occurs.
Prototype:
int print_char( uchar c, PRINT *p );
Parameters:
`co(11,1); uchar c`co();
A single byte to queue for printing.
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1;
...
print_char('\r', &printer1);
`co(10,1);/// print_data`co(); `keyword(source,[UW_PRINT.C]~print_data);
Prints a block of data. A 0 is returned if an error occurs.
Prototype:
int print_data( uchar *data, int cnt, PRINT *p );
Parameters:
`co(11,1); uchar *data`co();
A pointer to the data to queue for printing.
`co(11,1); int cnt`co();
The number of bytes to print.
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
uchar data[132];
PRINT printer1;
...
print_data(data, 132, &printer1);
`co(10,1);/// print_eol`co(); `keyword(source,[UW_PRINT.C]~print_eol);
Prints an end-of-line sequence. The print structure contains two
variables, "cr_cnt" and "lf_cnt" that control this sequence. For every
carriage return "cr_cnt", "lf_cnt" line feeds are printed.
For instance, the simple case of cr_cnt = lf_cnt = 1 outputs \r\n while
cr_cnt = 1, lf_cnt = 2 outputs \r\n\n. A 0 is returned if an error
occurs.
Prototype:
int print_eol( PRINT *p );
Parameters:
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1;
...
print_eol(&printer1);
`co(10,1);/// print_file`co(); `keyword(source,[UW_PRINT.C]~print_file);
Prints an entire file. The file is queued in "raw" format, no CR/LF
translation occurs. Make sure that there is enough room in the queue to
hold the entire file. A 0 is returned if an error occurs.
Prototype:
int print_file( char *fname, PRINT *p );
Parameters:
`co(11,1); char *fname`co();
A pointer to a string containing the filename/device to print to.
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1;
...
print_file("uw_help6.hlp", &printer1);
`co(10,1);/// print_screen`co(); `keyword(source,[UW_PRINT.C]~print_screen);
Prints the contents of the entire screen. A 0 is returned if an error
occurs.
Prototype:
int print_screen( PRINT *p );
Parameters:
`co(11,1); PRINT *p`co();
A pointer to a print queue structure.
Usage:
PRINT printer1;
...
print_screen(&printer1);
`co